import java.io.*;
import java.util.*;

public class WF {
    public static void main(String[] args) {
        // 验证命令行参数
        if (args.length != 2 || !args[0].equals("-c")) {
            System.err.println("用法: java WF -c <文件名>");
            System.exit(1);
        }

        String fileName = args[1];
        int[] counts = new int[26]; // 索引0-25对应A-Z
        long totalLetters = 0;

        // 高效读取文件（缓冲流+字节流）
        try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(fileName))) {
            int c;
            while ((c = bis.read()) != -1) {
                // 先判断是否为字母，再转为大写
                if (Character.isLetter(c)) {
                    char upperChar = Character.toUpperCase((char) c);
                    // 严格判断是否在A-Z范围内
                    if (upperChar >= 'A' && upperChar <= 'Z') {
                        int index = upperChar - 'A';
                        counts[index]++;
                        totalLetters++;
                    }
                }
            }
        } catch (FileNotFoundException e) {
            System.err.println("无法找到文件: " + fileName);
            System.exit(1);
        } catch (IOException e) {
            System.err.println("文件读取错误: " + e.getMessage());
            System.exit(1);
        }

        // 处理无字母的情况
        if (totalLetters == 0) {
            System.err.println("文件中未包含任何字母");
            System.exit(1);
        }

        // 构建字母-频率映射
        List<Map.Entry<Character, Double>> freqList = new ArrayList<>();
        for (int i = 0; i < 26; i++) {
            if (counts[i] > 0) {
                char letter = (char) ('A' + i);
                double frequency = (counts[i] * 100.0) / totalLetters;
                freqList.add(new AbstractMap.SimpleEntry<>(letter, frequency));
            }
        }

        // 排序：先按频率降序，频率相同则按字母升序
        freqList.sort((a, b) -> {
            int freqCompare = Double.compare(b.getValue(), a.getValue());
            return freqCompare != 0 ? freqCompare : Character.compare(a.getKey(), b.getKey());
        });

        // 输出结果（保留两位小数）
        for (Map.Entry<Character, Double> entry : freqList) {
            System.out.printf("%c: %.2f%%%n", entry.getKey(), entry.getValue());
        }
    }
}